package zero.tech.games.gate.controller;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.JSONObject;

import zero.tech.core.data.SimpleUser;
import zero.tech.games.common.RedisConsts;

public class BaseController {
	public SimpleUser getLoginUser(HttpServletRequest request) {
		SimpleUser simpleUser=null;
		String str=request.getHeader(RedisConsts.GATEWAY_USER);
		if(StringUtils.isNotBlank(str)) {
			try {
				str=URLDecoder.decode(str, "UTF-8");
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			simpleUser=JSONObject.parseObject(str, SimpleUser.class);
		}
		return simpleUser;
	}
}
